package controller

import (
	"fmt"
	"gin-chat/pkg"
	"gin-chat/router/request"
	"gin-chat/router/response"
	"gin-chat/service"
	"github.com/gin-gonic/gin"
	"net/http"
)

//聊天记录 暂时使用数据库存储
func ChatRecordPage(c *gin.Context) {
	app := &response.Gin{C: c}
	params := &request.ChatRecordPageRequest{}
	if err := c.ShouldBindJSON(params); err != nil {
		fmt.Println(err)
		app.Response(http.StatusInternalServerError, pkg.InvalidParams, nil)
		return
	}
	result, code := service.ChatRecordPage(params)
	if code != 0 {
		app.Response(http.StatusInternalServerError, code, nil)
		return
	}
	app.Response(http.StatusOK, pkg.Success, result)
}
